#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:item.py
# author:邹煜扬
# datetime:2024/12/18 16:25
# software: PyCharm
"""
this is function  description 
"""
# import module your need

class Item:
    def __init__(self, production, dot_position):
        self.production = production  # 产生式
        self.dot_position = dot_position  # 点的位置

    def after_dot_symbol(self):
        if self.dot_position < len(self.production.right):#点不在最后一个位置
            return self.production.right[self.dot_position]
        else:#点在最后一个位置
            self.dot_position = len(self.production.right)#确保点的位置是固定的，便于比较
            return None

    def __hash__(self):
        return hash((tuple(self.production), self.dot_position))

    def __eq__(self, other):
        return self.production == other.production and self.dot_position == other.dot_position

    def __repr__(self):
        return f"{self.production.left} -> {self.production.right[:self.dot_position]}.{self.production.right[self.dot_position:]}"
